<template>
    <div style="padding:20px;">
        <!--公司简介编辑-->
        <div class="common-navstyle" style="font-weight:normal;">公司简介编辑</div>
        <tinymce
        ref="editor"
        :tinymceObj="tinymceObj"
        v-model="content"
        @tinymcevalue="getValue"
        ></tinymce>
        <div style="padding-top:10px;">
            <el-button type="primary" @click="saveCompany">确定</el-button>
        </div>
    </div>
</template>
<script>
import api from '@/ajax/api-sl'
import tinymce from '@/components/Editor'
export default {
    data(){
        return {
            user: null,
            content:'',
            tinymceObj:{
                height:350,
                value:''
            }
        }
    },
    components:{
      tinymce
    },
    mounted(){
        this.reload();
        //this.html = sessionStorage.getItem('companyProfile');
    },
    methods:{
        async reload () {
            // this.user = await api.getUserByUserName(JSON.parse(sessionStorage.getItem('user')).username)
            // const res = await api.getBasicCompany({companyId: this.user.data.orgid});
            const res = await api.getBasicCompany({companyId: 1});
            if (res.code === '00000') {
                this.$refs.editor.myValue = res.data.content
            } else {
                this.$message.error(res.message);
            }
        },
        getValue(html){
            this.content = html;
        },
        async saveCompany(){
            // const res = await api.editBasicCompany({companyid: this.user.data.orgid, content: this.$refs.editor.myValue})
            const res = await api.editBasicCompany({companyid: 1, content: this.$refs.editor.myValue})
            if (res.code === '00000') {
                this.$message.success('提交保存成功')
          } else {
                this.$message.error(res.message);
          }
        }
    }
}
</script>
<style lang="scss" scoped>
$Color:#15428F;
$Bgnavtab:rgba(255,255,255,.5);
$BgHeader:#DFE8F6;
$BorderColor:#99bbe8;
.common-navstyle{
  color: $Color;font-weight: bold;line-height: 30px;border-radius: 3px;padding: 0 8px; background: linear-gradient(to bottom ,#fff,#deecfd,#fff); background-color:$Bgnavtab;
}
</style>